package com.chaopei.service.impl;

import com.chaopei.entity.Emp;
import com.chaopei.mapper.EmpMapper;
import com.chaopei.mapper.impl.EmpMapperImpl;
import com.chaopei.service.EmpService;

import java.util.List;

/**
 * @Author Corday 天涯
 * @Date 2022/3/23 15:42
 */
public class EmpServiceImpl implements EmpService {

    @Override
    public List<Emp> getAllEmps() {
        EmpMapper empMapper = new EmpMapperImpl();
        return empMapper.selectAllEmps();
    }

    @Override
    public String getEmp(Integer eno) {
        EmpMapper empMapper = new EmpMapperImpl();
        Emp emp = empMapper.selectEmpByEid(eno);
        return emp == null ? "查询出错" : emp.toString();
    }

    @Override
    public String changeEmp(Integer eno, Double salary) {
        EmpMapper empMapper = new EmpMapperImpl();
        Integer temp = empMapper.updateEmpByEid(eno, salary);
        return temp > 0 ? "更新成功!" : "更新失败!";
    }
}
